package cn.fsd.nacos;

import cn.fsd.domain.Transfer;
import cn.fsd.query.dispatch.TransferQuery;
import cn.fsd.vo.ResultBean;
import cn.fsd.vo.storeroom.transfer.TransferCommodityTaskVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import static cn.fsd.util.FeignConstant.DispatchServiceUrl;

@Component
@FeignClient(value = "dispatch-server",url = DispatchServiceUrl)
public interface DispatchServer {

    /**
     * 调用调度中心微服务接口，根据订单地址规划获得配送中心库房id
     * @param receiver_address 订单配送地址
     * @return 中心库房id
     */
    @GetMapping("/transfer/getStoreroom/{receiver_address}")
    ResultBean<String> getStoreroom(@PathVariable("receiver_address") String receiver_address);

    @GetMapping("/transfer/getByOrderId/{order_id}")
    @ApiOperation(value = "（CustomerService调用）根据order_id查询调拨单，从而得到中心库房id")
    Transfer findByOrderId(@PathVariable("order_id") String order_id);

    @GetMapping("/transfer/getById/{transfer_id}")
    @ApiOperation(value = "根据id查询调拨单")
    Transfer findById(@PathVariable("transfer_id") String transfer_id);

    @PostMapping("/transfer/findByStoreroomByPage")
    @ApiOperation(value = "查询某仓库需要调拨入库的调拨单VO,调拨单状态为'已调度'")
    PageInfo<TransferCommodityTaskVO> findByStoreroomByPage(@RequestBody TransferQuery query);

    @PostMapping("/transfer/findByStationByPage")
    @ApiOperation(value = "查询某仓库需要调拨出库的调拨单VO,调拨单状态为'已出库'")
    PageInfo<TransferCommodityTaskVO> findByStationByPage(@RequestBody TransferQuery query);

    @PostMapping("/transfer/changeStatus")
    @ApiOperation(value = "修改某调拨单的状态")
    Boolean changeStatus(@RequestBody Transfer transfer);

}
